<?php
/**
 * <b>RUBIK IT Solution & Development ltd.</b>
 *
 * PROJECT		: Rubik Ultimate Framework
 * @version 	: 1.1
 * COPYRIGHT    : 2008
 * ------------------------------------------------------
 * 
 * Created on	:  Jul 11, 2008
 * 
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );

RCoreImporter::cls("html.HtmlSqlCombobox" );

class HtmlSqlDbLanguageCombobox extends HtmlSqlCombobox {
	
	var $_languageDomain = 'static_list';
	
	function setLanguageDomain($domain) {
		$this->_languageDomain = $domain;
	}
	
	/**
	 * Create HTML text for the combobox
	 *
	 * @param string $emptyText the text for empty value. if this equal to null then there isn't any blank value in combobox
	 * @param string $cssCls
	 * @param string $style
	 * @param string $id
	 * @param string $extAttributes
	 * @return string
	 */
	function createCombobox($emptyText = "- - Select Filter - -", $cssCls = null, $style = null, $id = null, $extAttributes = "") {
		if (!$this->_dataFilled) {
			$db	= $this->_db;
			$db->setQuery ( $this->_sql );
			$result = $db->loadRowList ();
			
			foreach ( $result as $rec ) {
				$key = $rec [0];
				$val = SysDBLanguage::_($rec [1], $this->_languageDomain);
				$this->$key = $val;
			}
			
			$this->_dataFilled = true;
		}
		return parent::createCombobox($emptyText, $cssCls, $style, $id, $extAttributes);
	}
	
}
?>